
ROOT_BOOST=~/projects/boost
ROOT_ZOLTAN=~/projects/Zoltan_v3.6/src/
#TBB_ROOT=~/projects/tbb40/include  -L~/projects/tbb40/lib/ia32/

DISTRIBUTED_INCLUDE=-I. -I$(ROOT_BOOST) -I$(ROOT_ZOLTAN)include -I/home/e248/e248/takac/work/gsl/include
DISTRIBUTED_LIB_PATH= -L$(ROOT_BOOST)/bin.v2/libs/mpi/build/gcc-4.6.1/release/link-static/threading-multi -L$(ROOT_ZOLTAN) -L/home/e248/e248/takac/work/gsl/lib 

DISTRIBUTED_COMPILER_OPTIONS=-fopenmp -O3 -fpermissive -DHAVE_CONFIG_H -DAUTOTOOLS_BUILD   -DMPICH_IGNORE_CXX_SEEK 
#DISTRIBUTED_LINK= -lboost_mpi -lzoltan -lboost_timer -lboost_serialization -lboost_thread -lgsl -lgslcblas -lm 
DISTRIBUTED_LINK= -lgslcblas  -lboost_system -lboost_timer -lboost_chrono -lrt  -lboost_mpi -lboost_serialization -fopenmp  -lgsl -lm -lboost_thread

#===========================

#MKL_LIBS=    $(MKLROOT)/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group  $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_sequential.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread -lm


# compiler which should be used
MPICC = mpicc
MPICPP = mpicxx
#MPICPP = CC

#============================================================================================
# You should not modify the lines below

# Cluster Consolve Solver
buildClusterSolver:
	$(MPICPP)  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) \
	-o $(BUILD_FOLDER)ClusterSolver \
 	$(FRONTENDS)solvers/ClusterSolver.cpp \
 	$(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  

distributed_APPROX: buildClusterSolver
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A data/a1a.4/a1a  \
	-l 0.1 -t 3 -f 2 -c 1 -i 1 -I 1000 -T 2 -a 1 -S 0
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A data/a1a.4/a1a  \
	-l 0.1 -t 3 -f 2 -c 1 -i 1 -I 1000 -T 2

asfsafas:
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 0 -c 1 -i 1 -I 10 \
	-a 1   -S 0
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 0 -c 1 -i 1 -I 10 \
	   -S 0	
	
 	
 	
 	
testClusterSolver: buildClusterSolver
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 0 -c 1 -i 1 -I 1000
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 1 -c 1 -i 1 -I 1000	
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A data/a1a.4/a1a  \
	-l 0.1 -t 3 -f 2 -c 1 -i 1 -I 1000 -T 2

testResidualShift: buildClusterSolver
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 0 -c 1 -i 1 -T 20 -C 20 -S 0 -E testName
	mpirun -c 4 $(BUILD_FOLDER)ClusterSolver \
	 -A ../data/unittests/distributed \
	-b ../data/unittests/distributed \
	-l 0.1 -t 3 -f 0 -c 1 -i 1 -T 20 -C 20 -S 1 -E testName
 	
	 
#============================================================================================

distributed_unit_test:
	reset
	mpicxx  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_unit_test $(SRCFOLDER)test/distributed_unit_test.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  
	mpirun -c 6 $(BUILDFOLDER)distributed_unit_test
	
	
distributed_huge_experimentOLD:	
	reset
	mpicxx  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_huge_experiment $(EXPFOLDER)distributed_huge_experiment.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  
	mpirun -c 4 $(BUILDFOLDER)distributed_huge_experiment

distributed_huge_experiment_strategies:	
	reset
	mpicxx  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_huge_experiment $(EXPFOLDER)distributed_huge_strategies.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  
	mpirun -c 4 $(BUILDFOLDER)distributed_huge_experiment



distributed_huge_experiment:	
	reset
	/opt/scorep/bin/scorep --mpi --openmp  --nocompiler  --verbose=1 mpicxx -g  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_huge_experiment $(EXPFOLDER)distributed_huge_experiment.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)
	export SCOREP_ENABLE_TRACING=1  
	#mpirun -c 4 $(BUILDFOLDER)distributed_huge_experiment

distributed_svm_solver:
	reset
	mpicxx  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_svm_solver $(EXPFOLDER)distributed_svm_solver.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  
	mpirun -c 4 $(BUILDFOLDER)distributed_svm_solver
	
distributed_dual_svm_solver:
	reset
	mpicxx  $(DISTRIBUTED_COMPILER_OPTIONS) $(DISTRIBUTED_INCLUDE) -o $(BUILDFOLDER)distributed_dual_svm_solver $(EXPFOLDER)distributed_dual_svm_solver.cpp $(DISTRIBUTED_LIB_PATH)  $(DISTRIBUTED_LINK)  
	mpirun -c 4 $(BUILDFOLDER)distributed_dual_svm_solver
	







distributed_huge_problem_generator:	
	reset
	g++  -o $(BUILDFOLDER)distributed_problem_generator $(EXPFOLDER)distributed_problem_generator.cpp  -fopenmp -lgsl -lgslcblas -lm   
	./$(BUILDFOLDER)distributed_problem_generator
	
distributed_svm_parser:	
	reset
	g++  -o $(BUILDFOLDER)distributed_svm_parser $(EXPFOLDER)distributed_svm_parser.cpp  -fopenmp -lgsl -lgslcblas -lm   
	./$(BUILDFOLDER)distributed_svm_parser
	
